package com.sykj.qianxuezhan.controller;

import com.sykj.qianxuezhan.bean.ShopPost;
import com.sykj.qianxuezhan.server.ShopPostService;
import com.sykj.util.reponse.CommonEnum;
import com.sykj.util.reponse.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author QianXuezhan
 * @Date 2020/7/28 20:13
 * @Description: TODO
 */
@CrossOrigin
@RestController
@RequestMapping("/shopPost")
public class ShopPostController {

    @Autowired
    private ShopPostService shopPostService;

    /**
     * @Date:
     * @Description:  查询所有职位信息
     **/
    @RequestMapping("/queryShopPost")
    public  List<ShopPost>  queryShopPost(ShopPost shopPost){
        return   shopPostService.queryShopPost(shopPost);
    }

    /**
     * @Date:
     * @Description: 根据id删除职位信息
     *
     **/
    @RequestMapping("/updatePostDelId")
    public ResultBody  updatePostDelId(String  postId){
        System.out.println(postId+"----------------------------");
        shopPostService.updatePostDelId(postId);
        return  new ResultBody(CommonEnum.SUCCESS);
    }

    /**
     * @Date:
     * @Description:  修改职位信息
     *
     **/
    @RequestMapping(value="/updatePost",method = RequestMethod.POST)
    public  ResultBody  updatePost(ShopPost shopPost,String postDesc){
        shopPost.setPostDesc(postDesc);
        shopPostService.updatePost(shopPost);
        return  new ResultBody(CommonEnum.SUCCESS);
    }

/**
* @Description: 职位信息表添加
 **/
@RequestMapping(value="/addPost",method = RequestMethod.POST)
public  ResultBody  addPost(ShopPost shopPost,String postDesc){
    shopPost.setPostDesc(postDesc);
    shopPost.setPostDel("0");
    shopPostService.addPost(shopPost);
    return  new ResultBody(CommonEnum.SUCCESS);
}
}
